import { createStore } from 'vuex'

const getOptions = () => {
  let options = JSON.parse(localStorage.getItem('options'))
  return options
}

const getUser = () => {
  let userinformation = JSON.parse(localStorage.getItem('userinformation'))
  return userinformation
}
export default createStore({
  // 存储数据
  state() {
    return {
      count: 0,
      options: getOptions(),
      userinformation: getUser(),
    }
  },
  // mutations用于变更store中的数据
  mutations: {
    changeOption(state, options) {
      state.options = options
    },
    changeuser(state, data) {
      state.userinformation = data
    },
  },
})
